/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    display: grid;
    grid-template-areas: 
        "header header"
        "sidebar main";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 60px 1fr;
    height: 100vh;
}

/* Header Styles */
.header {
    grid-area: header;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 10px;
    color: #ecf0f1;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
}

.user-info i {
    font-size: 1.5rem;
}

/* Sidebar Styles */
.sidebar {
    grid-area: sidebar;
    background: #34495e;
    padding: 20px 0;
    box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}

.nav-menu {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #bdc3c7;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: #2c3e50;
    color: #ecf0f1;
}

.nav-item.active {
    background-color: #2c3e50;
    color: #3498db;
    border-left-color: #3498db;
}

.nav-item i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

/* Main Content Styles */
.main-content {
    grid-area: main;
    padding: 30px;
    overflow-y: auto;
    background-color: #ecf0f1;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
    font-weight: 300;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 2px solid #bdc3c7;
}

/* Dashboard Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.stats-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 20px;
    font-size: 1.5rem;
    color: white;
}

.stats-icon.products {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.stats-icon.workorders {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.stats-icon.production {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.stats-icon.progress {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.stats-info h3 {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stats-info p {
    color: #7f8c8d;
    font-size: 0.9rem;
}

/* Recent Activities */
.recent-activities {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.recent-activities h3 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.3rem;
}

.activity-list {
    max-height: 300px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #ecf0f1;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 0.9rem;
    color: white;
}

.activity-icon.production {
    background-color: #27ae60;
}

.activity-icon.rejection {
    background-color: #e74c3c;
}

.activity-icon.rework {
    background-color: #f39c12;
}

.activity-meta {
    font-size: 0.75rem;
    color: #95a5a6;
    margin-top: 2px;
}

/* No data and error states */
.no-data {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 40px 20px;
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
}

.error {
    text-align: center;
    color: #e74c3c;
    font-weight: 500;
    padding: 40px 20px;
    background: linear-gradient(135deg, #fdedec, #fadbd8);
}

.activity-content {
    flex: 1;
}

.activity-content h4 {
    color: #2c3e50;
    font-size: 0.9rem;
    margin-bottom: 3px;
}

.activity-content p {
    color: #7f8c8d;
    font-size: 0.8rem;
}

/* Search Bar */
.search-bar {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.search-bar input,
.search-bar select {
    padding: 10px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
    background: white;
}

.search-bar input:focus,
.search-bar select:focus {
    outline: none;
    border-color: #3498db;
}

.search-bar input {
    flex: 1;
    min-width: 200px;
}

.search-bar select {
    min-width: 150px;
}

/* Table Styles */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
    padding: 15px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #ecf0f1;
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background-color: #f8f9fa;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2980b9, #21618c);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.btn-success:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.btn-warning:hover {
    background: linear-gradient(135deg, #e67e22, #d35400);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-1px);
}

.btn-secondary {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #7f8c8d, #6c7b7d);
    transform: translateY(-1px);
}

.btn-group {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Status Badges */
.status-badge, .type-badge, .quality-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

/* Status Badge Colors */
.status-badge.pending {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-badge.in_progress, .status-badge.in-progress {
    background-color: #cce5ff;
    color: #004085;
    border: 1px solid #74b9ff;
}

.status-badge.completed {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #00b894;
}

.status-badge.cancelled {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #e17055;
}

/* Record Type Badge Colors */
.type-badge.production {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #00b894;
}

.type-badge.rejection {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #e17055;
}

.type-badge.rework {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Quality Badge Colors */
.quality-badge.qualified {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #00b894;
}

.quality-badge.unqualified {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #e17055;
}

.quality-badge.pending {
    background-color: #e2e3e5;
    color: #495057;
    border: 1px solid #ced4da;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 3% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 2px solid #ecf0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
    border-radius: 12px 12px 0 0;
}

.modal-title {
    color: white;
    font-size: 1.3rem;
    font-weight: 600;
    margin: 0;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
    background: none;
    border: none;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close:hover {
    background-color: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 25px;
    background-color: #f8f9fa;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 2px solid #ecf0f1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background-color: white;
    border-radius: 0 0 12px 12px;
}

/* Enhanced Form Styles */
.modal-form {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: 600;
    font-size: 0.9rem;
}

.required {
    color: #e74c3c;
    margin-left: 3px;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-control.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.form-control::placeholder {
    color: #95a5a6;
    font-style: italic;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 0;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 20px;
}

/* Textarea specific styling */
textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

/* Select specific styling */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
}

/* Input number styling */
input[type="number"].form-control {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Form validation states */
.form-control:valid {
    border-color: #27ae60;
}

.form-control:invalid:not(:focus) {
    border-color: #e74c3c;
}

/* Loading state for forms */
.form-loading {
    pointer-events: none;
    opacity: 0.6;
}

.form-loading .form-control {
    background-color: #f8f9fa;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1100;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    background: linear-gradient(135deg, #27ae60, #229954);
}

.toast.error {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.toast.warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

.toast.info {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

/* Loading States */
.loading {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    padding: 20px;
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        grid-template-areas: 
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 60px 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .main-content {
        padding: 15px;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-bar input,
    .search-bar select {
        width: 100%;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}